﻿namespace Digitalmes.Infrastructure.IntegrationTests;

/// <summary>
/// 测试基类。
/// </summary>
public abstract class BaseTestFixture
{
    /// <summary>
    /// 获取注册的服务接口。
    /// </summary>
    public IServiceProvider Services { get; }

    protected BaseTestFixture()
    {
        var hostBuilder = new HostBuilder();
        hostBuilder.ConfigureAppConfiguration((_, config) =>
        {
            config.AddJsonFile("appsettings.json");
        });
      
        hostBuilder.ConfigureServices((context, services) =>
        {
            Configure(services, context.Configuration);
        });

        var host = hostBuilder.Build();
        Services = host.Services;
    }

    /// <summary>
    /// 配置服务。
    /// </summary>
    /// <param name="services"></param>
    /// <param name="configuration"></param>
    protected virtual void Configure(IServiceCollection services, IConfiguration configuration)
    {
    }
}
